package com.ht.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ht.dto.CureDiary;
import com.ht.mapper.CureDiaryMapper;
import com.ht.service.ICureDiaryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 代齐园
 * @since 2022-05-28
 */
@Service
public class CureDiaryServiceImpl extends ServiceImpl<CureDiaryMapper, CureDiary> implements ICureDiaryService {

    @Resource
    private CureDiaryMapper cureDiaryMapper;

    @Override
    public void insertDiary(Long id,CureDiary cureDiary) {
        cureDiary.setUserId(id);
        cureDiaryMapper.insert(cureDiary);
    }

    @Override
    public List<CureDiary> getMyDiary(Long id) {
        QueryWrapper<CureDiary> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",id);
        List<CureDiary> cureDiaries = cureDiaryMapper.selectList(queryWrapper);
        return cureDiaries;


    }
}
